#include "Cannon.hpp"
#include "BattleField.hpp"

Cannon::Cannon(const Missile& m, float period)
	: m_main(m),
	m_T(period)
{

}

Cannon::~Cannon()
{
}

void Cannon::shoot()
{
    // can't shoot before m_T seconds elapsed since last shot
	if ( m_clock.GetElapsedTime() > m_T )
	{
	    // add a missile to the BattleField
		BF::get()->add(m_main);
		m_clock.Reset();
	}
}

void Cannon::setPosition(const float& x, const float& y)
{
	m_main.setPosition(x, y);
}

